{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>item_id</th>\n",
       "      <th>cate_id</th>\n",
       "      <th>action_type</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>view</th>\n",
       "      <th>deep_view</th>\n",
       "      <th>collect</th>\n",
       "      <th>share</th>\n",
       "      <th>comment</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>action_time</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:00</th>\n",
       "      <td>11482147</td>\n",
       "      <td>492681</td>\n",
       "      <td>1_11</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174400</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:00</th>\n",
       "      <td>12070750</td>\n",
       "      <td>457406</td>\n",
       "      <td>1_14</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174400</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:00</th>\n",
       "      <td>12431632</td>\n",
       "      <td>527476</td>\n",
       "      <td>1_1</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174400</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:00</th>\n",
       "      <td>13397746</td>\n",
       "      <td>531771</td>\n",
       "      <td>1_6</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174400</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:00</th>\n",
       "      <td>13794253</td>\n",
       "      <td>510089</td>\n",
       "      <td>1_27</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174400</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:00</th>\n",
       "      <td>14378544</td>\n",
       "      <td>535335</td>\n",
       "      <td>1_6</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174400</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:00</th>\n",
       "      <td>1705634</td>\n",
       "      <td>535202</td>\n",
       "      <td>1_10</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174400</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:00</th>\n",
       "      <td>6943823</td>\n",
       "      <td>478183</td>\n",
       "      <td>1_3</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174400</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:01</th>\n",
       "      <td>5902475</td>\n",
       "      <td>524378</td>\n",
       "      <td>1_6</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174401</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:02</th>\n",
       "      <td>12646404</td>\n",
       "      <td>529724</td>\n",
       "      <td>1_3</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174402</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:02</th>\n",
       "      <td>13156768</td>\n",
       "      <td>426867</td>\n",
       "      <td>1_17</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174402</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:02</th>\n",
       "      <td>14367772</td>\n",
       "      <td>484321</td>\n",
       "      <td>1_3</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174402</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:02</th>\n",
       "      <td>15967218</td>\n",
       "      <td>468533</td>\n",
       "      <td>1_3</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174402</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:02</th>\n",
       "      <td>7500423</td>\n",
       "      <td>531150</td>\n",
       "      <td>1_9</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174402</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:03</th>\n",
       "      <td>11227572</td>\n",
       "      <td>522855</td>\n",
       "      <td>1_17</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174403</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:03</th>\n",
       "      <td>12431632</td>\n",
       "      <td>534450</td>\n",
       "      <td>1_1</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174403</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:03</th>\n",
       "      <td>12799141</td>\n",
       "      <td>531289</td>\n",
       "      <td>1_1</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174403</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:03</th>\n",
       "      <td>14380477</td>\n",
       "      <td>535477</td>\n",
       "      <td>1_1</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174403</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:03</th>\n",
       "      <td>15894951</td>\n",
       "      <td>491934</td>\n",
       "      <td>1_23</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174403</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:03</th>\n",
       "      <td>15905528</td>\n",
       "      <td>432274</td>\n",
       "      <td>1_2</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174403</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:03</th>\n",
       "      <td>1904514</td>\n",
       "      <td>530486</td>\n",
       "      <td>1_13</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174403</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:03</th>\n",
       "      <td>2415271</td>\n",
       "      <td>535363</td>\n",
       "      <td>1_6</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174403</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:03</th>\n",
       "      <td>2472319</td>\n",
       "      <td>535334</td>\n",
       "      <td>1_23</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174403</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:03</th>\n",
       "      <td>6088961</td>\n",
       "      <td>533833</td>\n",
       "      <td>1_1</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174403</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:03</th>\n",
       "      <td>8350505</td>\n",
       "      <td>527149</td>\n",
       "      <td>1_6</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174403</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:04</th>\n",
       "      <td>11996914</td>\n",
       "      <td>530796</td>\n",
       "      <td>1_14</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174404</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:04</th>\n",
       "      <td>14378544</td>\n",
       "      <td>515907</td>\n",
       "      <td>1_6</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174404</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:04</th>\n",
       "      <td>16401821</td>\n",
       "      <td>535084</td>\n",
       "      <td>1_23</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174404</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:04</th>\n",
       "      <td>7908369</td>\n",
       "      <td>503571</td>\n",
       "      <td>1_23</td>\n",
       "      <td>view</td>\n",
       "      <td>1487174404</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-16 00:00:04</th>\n",
       "      <td>8462794</td>\n",
       "      <td>500412</td>\n",
       "      <td>1_12</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487174404</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:55</th>\n",
       "      <td>14503435</td>\n",
       "      <td>556944</td>\n",
       "      <td>1_11</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433595</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:55</th>\n",
       "      <td>14785354</td>\n",
       "      <td>557391</td>\n",
       "      <td>1_13</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433595</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:55</th>\n",
       "      <td>6046417</td>\n",
       "      <td>549425</td>\n",
       "      <td>1_3</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433595</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:55</th>\n",
       "      <td>7994897</td>\n",
       "      <td>542900</td>\n",
       "      <td>1_6</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433595</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:55</th>\n",
       "      <td>8046141</td>\n",
       "      <td>548638</td>\n",
       "      <td>1_3</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433595</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:56</th>\n",
       "      <td>13642170</td>\n",
       "      <td>557656</td>\n",
       "      <td>1_12</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433596</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:56</th>\n",
       "      <td>14597382</td>\n",
       "      <td>529781</td>\n",
       "      <td>3_2</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433596</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:56</th>\n",
       "      <td>15123124</td>\n",
       "      <td>542966</td>\n",
       "      <td>1_6</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433596</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:56</th>\n",
       "      <td>1552565</td>\n",
       "      <td>540172</td>\n",
       "      <td>1_6</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433596</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:56</th>\n",
       "      <td>16801260</td>\n",
       "      <td>557673</td>\n",
       "      <td>1_6</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433596</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:56</th>\n",
       "      <td>9526597</td>\n",
       "      <td>556855</td>\n",
       "      <td>1_1</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433596</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:57</th>\n",
       "      <td>13050562</td>\n",
       "      <td>522664</td>\n",
       "      <td>3_2</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433597</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:57</th>\n",
       "      <td>13375001</td>\n",
       "      <td>542997</td>\n",
       "      <td>1_3</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433597</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:57</th>\n",
       "      <td>14597382</td>\n",
       "      <td>524113</td>\n",
       "      <td>3_2</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433597</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:57</th>\n",
       "      <td>15488166</td>\n",
       "      <td>555820</td>\n",
       "      <td>1_6</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433597</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:57</th>\n",
       "      <td>16243453</td>\n",
       "      <td>557432</td>\n",
       "      <td>1_23</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433597</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:57</th>\n",
       "      <td>16487497</td>\n",
       "      <td>545043</td>\n",
       "      <td>1_6</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433597</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:57</th>\n",
       "      <td>17026753</td>\n",
       "      <td>543007</td>\n",
       "      <td>1_1</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433597</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:58</th>\n",
       "      <td>11283320</td>\n",
       "      <td>553331</td>\n",
       "      <td>1_6</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433598</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:58</th>\n",
       "      <td>12982345</td>\n",
       "      <td>514928</td>\n",
       "      <td>1_6</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433598</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:58</th>\n",
       "      <td>1469607</td>\n",
       "      <td>555989</td>\n",
       "      <td>1_6</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433598</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:58</th>\n",
       "      <td>3063774</td>\n",
       "      <td>557764</td>\n",
       "      <td>1_2</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433598</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:58</th>\n",
       "      <td>9121520</td>\n",
       "      <td>552734</td>\n",
       "      <td>1_1</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433598</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:59</th>\n",
       "      <td>10383492</td>\n",
       "      <td>536548</td>\n",
       "      <td>1_1</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433599</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:59</th>\n",
       "      <td>13006837</td>\n",
       "      <td>552829</td>\n",
       "      <td>1_9</td>\n",
       "      <td>deep_view</td>\n",
       "      <td>1487433599</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:59</th>\n",
       "      <td>13992209</td>\n",
       "      <td>548120</td>\n",
       "      <td>1_11</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433599</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:59</th>\n",
       "      <td>14597382</td>\n",
       "      <td>453373</td>\n",
       "      <td>3_2</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433599</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:59</th>\n",
       "      <td>16699556</td>\n",
       "      <td>523378</td>\n",
       "      <td>3_6</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433599</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:59</th>\n",
       "      <td>4496330</td>\n",
       "      <td>557706</td>\n",
       "      <td>1_6</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433599</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-18 23:59:59</th>\n",
       "      <td>9391042</td>\n",
       "      <td>555820</td>\n",
       "      <td>1_6</td>\n",
       "      <td>view</td>\n",
       "      <td>1487433599</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3272043 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                      user_id item_id cate_id action_type   timestamp  view  \\\n",
       "action_time                                                                   \n",
       "2017-02-16 00:00:00  11482147  492681    1_11        view  1487174400     1   \n",
       "2017-02-16 00:00:00  12070750  457406    1_14   deep_view  1487174400     0   \n",
       "2017-02-16 00:00:00  12431632  527476     1_1        view  1487174400     1   \n",
       "2017-02-16 00:00:00  13397746  531771     1_6   deep_view  1487174400     0   \n",
       "2017-02-16 00:00:00  13794253  510089    1_27   deep_view  1487174400     0   \n",
       "2017-02-16 00:00:00  14378544  535335     1_6   deep_view  1487174400     0   \n",
       "2017-02-16 00:00:00   1705634  535202    1_10        view  1487174400     1   \n",
       "2017-02-16 00:00:00   6943823  478183     1_3   deep_view  1487174400     0   \n",
       "2017-02-16 00:00:01   5902475  524378     1_6        view  1487174401     1   \n",
       "2017-02-16 00:00:02  12646404  529724     1_3        view  1487174402     1   \n",
       "2017-02-16 00:00:02  13156768  426867    1_17        view  1487174402     1   \n",
       "2017-02-16 00:00:02  14367772  484321     1_3        view  1487174402     1   \n",
       "2017-02-16 00:00:02  15967218  468533     1_3   deep_view  1487174402     0   \n",
       "2017-02-16 00:00:02   7500423  531150     1_9   deep_view  1487174402     0   \n",
       "2017-02-16 00:00:03  11227572  522855    1_17   deep_view  1487174403     0   \n",
       "2017-02-16 00:00:03  12431632  534450     1_1   deep_view  1487174403     0   \n",
       "2017-02-16 00:00:03  12799141  531289     1_1        view  1487174403     1   \n",
       "2017-02-16 00:00:03  14380477  535477     1_1   deep_view  1487174403     0   \n",
       "2017-02-16 00:00:03  15894951  491934    1_23        view  1487174403     1   \n",
       "2017-02-16 00:00:03  15905528  432274     1_2   deep_view  1487174403     0   \n",
       "2017-02-16 00:00:03   1904514  530486    1_13        view  1487174403     1   \n",
       "2017-02-16 00:00:03   2415271  535363     1_6        view  1487174403     1   \n",
       "2017-02-16 00:00:03   2472319  535334    1_23        view  1487174403     1   \n",
       "2017-02-16 00:00:03   6088961  533833     1_1   deep_view  1487174403     0   \n",
       "2017-02-16 00:00:03   8350505  527149     1_6   deep_view  1487174403     0   \n",
       "2017-02-16 00:00:04  11996914  530796    1_14        view  1487174404     1   \n",
       "2017-02-16 00:00:04  14378544  515907     1_6        view  1487174404     1   \n",
       "2017-02-16 00:00:04  16401821  535084    1_23   deep_view  1487174404     0   \n",
       "2017-02-16 00:00:04   7908369  503571    1_23        view  1487174404     1   \n",
       "2017-02-16 00:00:04   8462794  500412    1_12   deep_view  1487174404     0   \n",
       "...                       ...     ...     ...         ...         ...   ...   \n",
       "2017-02-18 23:59:55  14503435  556944    1_11        view  1487433595     1   \n",
       "2017-02-18 23:59:55  14785354  557391    1_13        view  1487433595     1   \n",
       "2017-02-18 23:59:55   6046417  549425     1_3        view  1487433595     1   \n",
       "2017-02-18 23:59:55   7994897  542900     1_6   deep_view  1487433595     0   \n",
       "2017-02-18 23:59:55   8046141  548638     1_3        view  1487433595     1   \n",
       "2017-02-18 23:59:56  13642170  557656    1_12   deep_view  1487433596     0   \n",
       "2017-02-18 23:59:56  14597382  529781     3_2        view  1487433596     1   \n",
       "2017-02-18 23:59:56  15123124  542966     1_6   deep_view  1487433596     0   \n",
       "2017-02-18 23:59:56   1552565  540172     1_6   deep_view  1487433596     0   \n",
       "2017-02-18 23:59:56  16801260  557673     1_6   deep_view  1487433596     0   \n",
       "2017-02-18 23:59:56   9526597  556855     1_1   deep_view  1487433596     0   \n",
       "2017-02-18 23:59:57  13050562  522664     3_2        view  1487433597     1   \n",
       "2017-02-18 23:59:57  13375001  542997     1_3   deep_view  1487433597     0   \n",
       "2017-02-18 23:59:57  14597382  524113     3_2        view  1487433597     1   \n",
       "2017-02-18 23:59:57  15488166  555820     1_6   deep_view  1487433597     0   \n",
       "2017-02-18 23:59:57  16243453  557432    1_23        view  1487433597     1   \n",
       "2017-02-18 23:59:57  16487497  545043     1_6   deep_view  1487433597     0   \n",
       "2017-02-18 23:59:57  17026753  543007     1_1   deep_view  1487433597     0   \n",
       "2017-02-18 23:59:58  11283320  553331     1_6   deep_view  1487433598     0   \n",
       "2017-02-18 23:59:58  12982345  514928     1_6   deep_view  1487433598     0   \n",
       "2017-02-18 23:59:58   1469607  555989     1_6        view  1487433598     1   \n",
       "2017-02-18 23:59:58   3063774  557764     1_2   deep_view  1487433598     0   \n",
       "2017-02-18 23:59:58   9121520  552734     1_1   deep_view  1487433598     0   \n",
       "2017-02-18 23:59:59  10383492  536548     1_1        view  1487433599     1   \n",
       "2017-02-18 23:59:59  13006837  552829     1_9   deep_view  1487433599     0   \n",
       "2017-02-18 23:59:59  13992209  548120    1_11        view  1487433599     1   \n",
       "2017-02-18 23:59:59  14597382  453373     3_2        view  1487433599     1   \n",
       "2017-02-18 23:59:59  16699556  523378     3_6        view  1487433599     1   \n",
       "2017-02-18 23:59:59   4496330  557706     1_6        view  1487433599     1   \n",
       "2017-02-18 23:59:59   9391042  555820     1_6        view  1487433599     1   \n",
       "\n",
       "                     deep_view  collect  share  comment  \n",
       "action_time                                              \n",
       "2017-02-16 00:00:00          0        0      0        0  \n",
       "2017-02-16 00:00:00          1        0      0        0  \n",
       "2017-02-16 00:00:00          0        0      0        0  \n",
       "2017-02-16 00:00:00          1        0      0        0  \n",
       "2017-02-16 00:00:00          1        0      0        0  \n",
       "2017-02-16 00:00:00          1        0      0        0  \n",
       "2017-02-16 00:00:00          0        0      0        0  \n",
       "2017-02-16 00:00:00          1        0      0        0  \n",
       "2017-02-16 00:00:01          0        0      0        0  \n",
       "2017-02-16 00:00:02          0        0      0        0  \n",
       "2017-02-16 00:00:02          0        0      0        0  \n",
       "2017-02-16 00:00:02          0        0      0        0  \n",
       "2017-02-16 00:00:02          1        0      0        0  \n",
       "2017-02-16 00:00:02          1        0      0        0  \n",
       "2017-02-16 00:00:03          1        0      0        0  \n",
       "2017-02-16 00:00:03          1        0      0        0  \n",
       "2017-02-16 00:00:03          0        0      0        0  \n",
       "2017-02-16 00:00:03          1        0      0        0  \n",
       "2017-02-16 00:00:03          0        0      0        0  \n",
       "2017-02-16 00:00:03          1        0      0        0  \n",
       "2017-02-16 00:00:03          0        0      0        0  \n",
       "2017-02-16 00:00:03          0        0      0        0  \n",
       "2017-02-16 00:00:03          0        0      0        0  \n",
       "2017-02-16 00:00:03          1        0      0        0  \n",
       "2017-02-16 00:00:03          1        0      0        0  \n",
       "2017-02-16 00:00:04          0        0      0        0  \n",
       "2017-02-16 00:00:04          0        0      0        0  \n",
       "2017-02-16 00:00:04          1        0      0        0  \n",
       "2017-02-16 00:00:04          0        0      0        0  \n",
       "2017-02-16 00:00:04          1        0      0        0  \n",
       "...                        ...      ...    ...      ...  \n",
       "2017-02-18 23:59:55          0        0      0        0  \n",
       "2017-02-18 23:59:55          0        0      0        0  \n",
       "2017-02-18 23:59:55          0        0      0        0  \n",
       "2017-02-18 23:59:55          1        0      0        0  \n",
       "2017-02-18 23:59:55          0        0      0        0  \n",
       "2017-02-18 23:59:56          1        0      0        0  \n",
       "2017-02-18 23:59:56          0        0      0        0  \n",
       "2017-02-18 23:59:56          1        0      0        0  \n",
       "2017-02-18 23:59:56          1        0      0        0  \n",
       "2017-02-18 23:59:56          1        0      0        0  \n",
       "2017-02-18 23:59:56          1        0      0        0  \n",
       "2017-02-18 23:59:57          0        0      0        0  \n",
       "2017-02-18 23:59:57          1        0      0        0  \n",
       "2017-02-18 23:59:57          0        0      0        0  \n",
       "2017-02-18 23:59:57          1        0      0        0  \n",
       "2017-02-18 23:59:57          0        0      0        0  \n",
       "2017-02-18 23:59:57          1        0      0        0  \n",
       "2017-02-18 23:59:57          1        0      0        0  \n",
       "2017-02-18 23:59:58          1        0      0        0  \n",
       "2017-02-18 23:59:58          1        0      0        0  \n",
       "2017-02-18 23:59:58          0        0      0        0  \n",
       "2017-02-18 23:59:58          1        0      0        0  \n",
       "2017-02-18 23:59:58          1        0      0        0  \n",
       "2017-02-18 23:59:59          0        0      0        0  \n",
       "2017-02-18 23:59:59          1        0      0        0  \n",
       "2017-02-18 23:59:59          0        0      0        0  \n",
       "2017-02-18 23:59:59          0        0      0        0  \n",
       "2017-02-18 23:59:59          0        0      0        0  \n",
       "2017-02-18 23:59:59          0        0      0        0  \n",
       "2017-02-18 23:59:59          0        0      0        0  \n",
       "\n",
       "[3272043 rows x 10 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train = pd.read_pickle('../pkl/process.train.pkl')\n",
    "train"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "day1 = train['2017-02-16 00:00:00':'2017-02-16 23:59:59']\n",
    "day2 = train['2017-02-17 00:00:00':'2017-02-17 23:59:59']\n",
    "day3 = train['2017-02-18 00:00:00':'2017-02-18 23:59:59']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def output_most_popular(df, k):\n",
    "    dft = df[['user_id','item_id','cate_id']].groupby(['cate_id','item_id']).count()\n",
    "    dft = dft.sort_values('user_id', ascending=False)\n",
    "    dft['item_id'] = [x[1] for x in dft.index]\n",
    "    dft['cate_id'] = [x[0] for x in dft.index]\n",
    "    return pd.DataFrame(data=dft.values[:,[2,0]], columns=['cate_id' + k,'cnt' + k], index=dft.values[:,1])\n",
    "\n",
    "def jizei(zei):\n",
    "    for i in zei:\n",
    "        if i != 0:\n",
    "            return i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'day1' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-13-5242abeb5953>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mday1pop\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0moutput_most_popular\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mday1\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m'1'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m \u001b[0mday2pop\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0moutput_most_popular\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mday2\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m'2'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[0mday3pop\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0moutput_most_popular\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mday3\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m'3'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[1;31m# print(day1pop.head(10))\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'day1' is not defined"
     ]
    }
   ],
   "source": [
    "day1pop = output_most_popular(day1,'1')\n",
    "day2pop = output_most_popular(day2,'2')\n",
    "day3pop = output_most_popular(day3,'3')\n",
    "\n",
    "# print(day1pop.head(10))\n",
    "# print(day2pop.head(10))\n",
    "# print(day3pop.head(10))\n",
    "day_join = day3pop.join(day2pop, how='outer').join(day1pop, how='outer').fillna(0)\n",
    "day_join['diff21'] = day_join.cnt2 - day_join.cnt1\n",
    "day_join['diff32'] = day_join.cnt3 - day_join.cnt2\n",
    "day_join['cate_id'] = [jizei(x) for x in day_join.values[:,[0,2,4]]]\n",
    "del day_join['cate_id3']\n",
    "del day_join['cate_id2']\n",
    "del day_join['cate_id1']\n",
    "day_join = day_join[['cate_id','cnt1','cnt2','cnt3','diff32','diff21']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>cate_id</th>\n",
       "      <th>cnt1</th>\n",
       "      <th>cnt2</th>\n",
       "      <th>cnt3</th>\n",
       "      <th>diff32</th>\n",
       "      <th>diff21</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>549608</th>\n",
       "      <td>1_6</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>9032</td>\n",
       "      <td>9030</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550192</th>\n",
       "      <td>1_1</td>\n",
       "      <td>0</td>\n",
       "      <td>45</td>\n",
       "      <td>7939</td>\n",
       "      <td>7894</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550039</th>\n",
       "      <td>1_6</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>5529</td>\n",
       "      <td>5521</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>542524</th>\n",
       "      <td>1_3</td>\n",
       "      <td>25</td>\n",
       "      <td>3932</td>\n",
       "      <td>4554</td>\n",
       "      <td>622</td>\n",
       "      <td>3907</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>542113</th>\n",
       "      <td>1_2</td>\n",
       "      <td>19</td>\n",
       "      <td>874</td>\n",
       "      <td>4471</td>\n",
       "      <td>3597</td>\n",
       "      <td>855</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550351</th>\n",
       "      <td>1_1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4308</td>\n",
       "      <td>4308</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>549609</th>\n",
       "      <td>1_6</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4287</td>\n",
       "      <td>4287</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>549536</th>\n",
       "      <td>1_3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4137</td>\n",
       "      <td>4137</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550001</th>\n",
       "      <td>1_1</td>\n",
       "      <td>0</td>\n",
       "      <td>51</td>\n",
       "      <td>3500</td>\n",
       "      <td>3449</td>\n",
       "      <td>51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>542163</th>\n",
       "      <td>1_6</td>\n",
       "      <td>27</td>\n",
       "      <td>2180</td>\n",
       "      <td>3494</td>\n",
       "      <td>1314</td>\n",
       "      <td>2153</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550286</th>\n",
       "      <td>1_11</td>\n",
       "      <td>0</td>\n",
       "      <td>10</td>\n",
       "      <td>3479</td>\n",
       "      <td>3469</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>547033</th>\n",
       "      <td>1_3</td>\n",
       "      <td>0</td>\n",
       "      <td>229</td>\n",
       "      <td>3396</td>\n",
       "      <td>3167</td>\n",
       "      <td>229</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>542584</th>\n",
       "      <td>1_1</td>\n",
       "      <td>72</td>\n",
       "      <td>1098</td>\n",
       "      <td>3281</td>\n",
       "      <td>2183</td>\n",
       "      <td>1026</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550187</th>\n",
       "      <td>1_1</td>\n",
       "      <td>0</td>\n",
       "      <td>34</td>\n",
       "      <td>3237</td>\n",
       "      <td>3203</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>542515</th>\n",
       "      <td>1_6</td>\n",
       "      <td>42</td>\n",
       "      <td>1346</td>\n",
       "      <td>3234</td>\n",
       "      <td>1888</td>\n",
       "      <td>1304</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>549743</th>\n",
       "      <td>1_3</td>\n",
       "      <td>0</td>\n",
       "      <td>14</td>\n",
       "      <td>3155</td>\n",
       "      <td>3141</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>549850</th>\n",
       "      <td>1_11</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>3045</td>\n",
       "      <td>3038</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550319</th>\n",
       "      <td>1_6</td>\n",
       "      <td>0</td>\n",
       "      <td>28</td>\n",
       "      <td>3020</td>\n",
       "      <td>2992</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>547419</th>\n",
       "      <td>1_3</td>\n",
       "      <td>0</td>\n",
       "      <td>804</td>\n",
       "      <td>2910</td>\n",
       "      <td>2106</td>\n",
       "      <td>804</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>543092</th>\n",
       "      <td>1_1</td>\n",
       "      <td>68</td>\n",
       "      <td>4830</td>\n",
       "      <td>2561</td>\n",
       "      <td>-2269</td>\n",
       "      <td>4762</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550230</th>\n",
       "      <td>1_1</td>\n",
       "      <td>0</td>\n",
       "      <td>15</td>\n",
       "      <td>2488</td>\n",
       "      <td>2473</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>542703</th>\n",
       "      <td>1_2</td>\n",
       "      <td>17</td>\n",
       "      <td>1162</td>\n",
       "      <td>2472</td>\n",
       "      <td>1310</td>\n",
       "      <td>1145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>542055</th>\n",
       "      <td>1_6</td>\n",
       "      <td>10</td>\n",
       "      <td>900</td>\n",
       "      <td>2466</td>\n",
       "      <td>1566</td>\n",
       "      <td>890</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550702</th>\n",
       "      <td>1_6</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2463</td>\n",
       "      <td>2463</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550129</th>\n",
       "      <td>1_11</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "      <td>2427</td>\n",
       "      <td>2415</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550352</th>\n",
       "      <td>1_1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2362</td>\n",
       "      <td>2362</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>549835</th>\n",
       "      <td>1_1</td>\n",
       "      <td>0</td>\n",
       "      <td>55</td>\n",
       "      <td>2310</td>\n",
       "      <td>2255</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>547887</th>\n",
       "      <td>1_3</td>\n",
       "      <td>0</td>\n",
       "      <td>274</td>\n",
       "      <td>2303</td>\n",
       "      <td>2029</td>\n",
       "      <td>274</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>542718</th>\n",
       "      <td>1_3</td>\n",
       "      <td>13</td>\n",
       "      <td>1431</td>\n",
       "      <td>2291</td>\n",
       "      <td>860</td>\n",
       "      <td>1418</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>548243</th>\n",
       "      <td>1_3</td>\n",
       "      <td>0</td>\n",
       "      <td>958</td>\n",
       "      <td>2225</td>\n",
       "      <td>1267</td>\n",
       "      <td>958</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462542</th>\n",
       "      <td>1_1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516821</th>\n",
       "      <td>1_14</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462550</th>\n",
       "      <td>1_2</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "      <td>-2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462552</th>\n",
       "      <td>1_9</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516896</th>\n",
       "      <td>1_2</td>\n",
       "      <td>8</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "      <td>-6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462567</th>\n",
       "      <td>1_12</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516890</th>\n",
       "      <td>1_17</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516881</th>\n",
       "      <td>1_17</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462574</th>\n",
       "      <td>1_12</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516878</th>\n",
       "      <td>1_6</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462575</th>\n",
       "      <td>1_9</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>-6</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516875</th>\n",
       "      <td>1_17</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462578</th>\n",
       "      <td>1_17</td>\n",
       "      <td>12</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462581</th>\n",
       "      <td>1_1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>-3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516862</th>\n",
       "      <td>1_6</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462590</th>\n",
       "      <td>1_17</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>-4</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462592</th>\n",
       "      <td>1_8</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>-4</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516855</th>\n",
       "      <td>1_14</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462594</th>\n",
       "      <td>1_3</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>-6</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462597</th>\n",
       "      <td>1_15</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462601</th>\n",
       "      <td>1_23</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516841</th>\n",
       "      <td>1_14</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>-4</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516840</th>\n",
       "      <td>1_23</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>-3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462608</th>\n",
       "      <td>1_11</td>\n",
       "      <td>8</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>-6</td>\n",
       "      <td>-2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>462609</th>\n",
       "      <td>1_3</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516829</th>\n",
       "      <td>3_2</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516828</th>\n",
       "      <td>1_14</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>-3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516827</th>\n",
       "      <td>1_6</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>-5</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>516826</th>\n",
       "      <td>1_16</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>-2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15213</th>\n",
       "      <td>1_3</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>65214 rows × 6 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       cate_id  cnt1  cnt2  cnt3  diff32  diff21\n",
       "549608     1_6     0     2  9032    9030       2\n",
       "550192     1_1     0    45  7939    7894      45\n",
       "550039     1_6     0     8  5529    5521       8\n",
       "542524     1_3    25  3932  4554     622    3907\n",
       "542113     1_2    19   874  4471    3597     855\n",
       "550351     1_1     0     0  4308    4308       0\n",
       "549609     1_6     0     0  4287    4287       0\n",
       "549536     1_3     0     0  4137    4137       0\n",
       "550001     1_1     0    51  3500    3449      51\n",
       "542163     1_6    27  2180  3494    1314    2153\n",
       "550286    1_11     0    10  3479    3469      10\n",
       "547033     1_3     0   229  3396    3167     229\n",
       "542584     1_1    72  1098  3281    2183    1026\n",
       "550187     1_1     0    34  3237    3203      34\n",
       "542515     1_6    42  1346  3234    1888    1304\n",
       "549743     1_3     0    14  3155    3141      14\n",
       "549850    1_11     0     7  3045    3038       7\n",
       "550319     1_6     0    28  3020    2992      28\n",
       "547419     1_3     0   804  2910    2106     804\n",
       "543092     1_1    68  4830  2561   -2269    4762\n",
       "550230     1_1     0    15  2488    2473      15\n",
       "542703     1_2    17  1162  2472    1310    1145\n",
       "542055     1_6    10   900  2466    1566     890\n",
       "550702     1_6     0     0  2463    2463       0\n",
       "550129    1_11     0    12  2427    2415      12\n",
       "550352     1_1     0     0  2362    2362       0\n",
       "549835     1_1     0    55  2310    2255      55\n",
       "547887     1_3     0   274  2303    2029     274\n",
       "542718     1_3    13  1431  2291     860    1418\n",
       "548243     1_3     0   958  2225    1267     958\n",
       "...        ...   ...   ...   ...     ...     ...\n",
       "462542     1_1     2     0     0       0      -2\n",
       "516821    1_14     6     0     0       0      -6\n",
       "462550     1_2     4     2     0      -2      -2\n",
       "462552     1_9     2     2     0      -2       0\n",
       "516896     1_2     8     2     0      -2      -6\n",
       "462567    1_12     0     2     0      -2       2\n",
       "516890    1_17     2     0     0       0      -2\n",
       "516881    1_17     2     0     0       0      -2\n",
       "462574    1_12     2     0     0       0      -2\n",
       "516878     1_6     5     0     0       0      -5\n",
       "462575     1_9     0     6     0      -6       6\n",
       "516875    1_17     2     0     0       0      -2\n",
       "462578    1_17    12     0     0       0     -12\n",
       "462581     1_1     0     3     0      -3       3\n",
       "516862     1_6     9     0     0       0      -9\n",
       "462590    1_17     0     4     0      -4       4\n",
       "462592     1_8     0     4     0      -4       4\n",
       "516855    1_14     2     0     0       0      -2\n",
       "462594     1_3     2     6     0      -6       4\n",
       "462597    1_15     5     0     0       0      -5\n",
       "462601    1_23     2     0     0       0      -2\n",
       "516841    1_14     3     4     0      -4       1\n",
       "516840    1_23     0     3     0      -3       3\n",
       "462608    1_11     8     6     0      -6      -2\n",
       "462609     1_3     0     1     0      -1       1\n",
       "516829     3_2     0     2     0      -2       2\n",
       "516828    1_14     0     3     0      -3       3\n",
       "516827     1_6     0     5     0      -5       5\n",
       "516826    1_16     0     2     0      -2       2\n",
       "15213      1_3     1     0     0       0      -1\n",
       "\n",
       "[65214 rows x 6 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "day_join= pd.read_pickle('../pkl/day.join.pkl')\n",
    "day_join[['cate_id','cnt1','cnt2','cnt3','diff32','diff21']].sort_values('cnt3', ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>view</th>\n",
       "      <th>deep_view</th>\n",
       "      <th>collect</th>\n",
       "      <th>share</th>\n",
       "      <th>comment</th>\n",
       "      <th>score</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>cate_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1_1</th>\n",
       "      <td>43</td>\n",
       "      <td>27</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_5</th>\n",
       "      <td>24</td>\n",
       "      <td>18</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_6</th>\n",
       "      <td>26</td>\n",
       "      <td>14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_11</th>\n",
       "      <td>16</td>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_27</th>\n",
       "      <td>11</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_2</th>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3_2</th>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_17</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_23</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3_8</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         view  deep_view  collect  share  comment  score\n",
       "cate_id                                                 \n",
       "1_1        43         27        0      0        0     97\n",
       "1_5        24         18        0      0        0     60\n",
       "1_6        26         14        0      0        0     54\n",
       "1_11       16         10        0      0        0     36\n",
       "1_27       11          6        0      0        0     23\n",
       "1_2         5          4        0      0        0     13\n",
       "3_2         4          4        0      0        0     12\n",
       "1_17        2          2        0      0        0      6\n",
       "1_23        1          1        0      0        0      3\n",
       "3_8         1          1        0      0        0      3"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "baseline = pd.read_pickle('../pkl/baseline.pkl')\n",
    "baseline.loc['15775343'].sort_values('score', ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>view</th>\n",
       "      <th>deep_view</th>\n",
       "      <th>collect</th>\n",
       "      <th>share</th>\n",
       "      <th>comment</th>\n",
       "      <th>score</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>cate_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1_1</th>\n",
       "      <td>18</td>\n",
       "      <td>12</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_3</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_13</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_18</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_2</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         view  deep_view  collect  share  comment  score\n",
       "cate_id                                                 \n",
       "1_1        18         12        0      0        0     42\n",
       "1_3         1          1        0      0        0      3\n",
       "1_13        1          0        0      0        0      1\n",
       "1_18        1          0        0      0        0      1\n",
       "1_2         1          0        0      0        0      1"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "baseline.loc['14621284'].sort_values('score', ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>view</th>\n",
       "      <th>deep_view</th>\n",
       "      <th>collect</th>\n",
       "      <th>share</th>\n",
       "      <th>comment</th>\n",
       "      <th>score</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>cate_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1_1</th>\n",
       "      <td>10</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_6</th>\n",
       "      <td>9</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_3</th>\n",
       "      <td>8</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_8</th>\n",
       "      <td>8</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         view  deep_view  collect  share  comment  score\n",
       "cate_id                                                 \n",
       "1_1        10          9        0      0        0     28\n",
       "1_6         9          8        0      0        0     25\n",
       "1_3         8          7        0      0        0     22\n",
       "1_8         8          7        0      0        0     22"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "baseline.loc['11022650'].sort_values('score', ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>view</th>\n",
       "      <th>deep_view</th>\n",
       "      <th>collect</th>\n",
       "      <th>share</th>\n",
       "      <th>comment</th>\n",
       "      <th>score</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>cate_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1_6</th>\n",
       "      <td>15</td>\n",
       "      <td>14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_11</th>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_3</th>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_1</th>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         view  deep_view  collect  share  comment  score\n",
       "cate_id                                                 \n",
       "1_6        15         14        0      0        0     43\n",
       "1_11        6          6        0      0        0     18\n",
       "1_3         6          6        0      0        0     18\n",
       "1_1         4          4        0      0        0     12"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "baseline.loc['2539552'].sort_values('score', ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>view</th>\n",
       "      <th>deep_view</th>\n",
       "      <th>collect</th>\n",
       "      <th>share</th>\n",
       "      <th>comment</th>\n",
       "      <th>score</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>cate_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1_1</th>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_2</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_10</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_23</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_3</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_6</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_7</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_9</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         view  deep_view  collect  share  comment  score\n",
       "cate_id                                                 \n",
       "1_1         8          8        0      0        0     24\n",
       "1_2         3          3        0      0        0      9\n",
       "1_10        1          1        0      0        0      3\n",
       "1_23        1          1        0      0        0      3\n",
       "1_3         1          1        0      0        0      3\n",
       "1_6         1          1        0      0        0      3\n",
       "1_7         1          1        0      0        0      3\n",
       "1_9         1          1        0      0        0      3"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "baseline.loc['5445998'].sort_values('score', ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>view</th>\n",
       "      <th>deep_view</th>\n",
       "      <th>collect</th>\n",
       "      <th>share</th>\n",
       "      <th>comment</th>\n",
       "      <th>score</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>cate_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1_6</th>\n",
       "      <td>30</td>\n",
       "      <td>27</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_1</th>\n",
       "      <td>21</td>\n",
       "      <td>14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_3</th>\n",
       "      <td>13</td>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_2</th>\n",
       "      <td>11</td>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_11</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_27</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_15</th>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_16</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_17</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_4</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_9</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         view  deep_view  collect  share  comment  score\n",
       "cate_id                                                 \n",
       "1_6        30         27        0      0        0     84\n",
       "1_1        21         14        0      0        0     49\n",
       "1_3        13         10        0      0        0     33\n",
       "1_2        11         10        0      0        0     31\n",
       "1_11        3          3        0      0        0      9\n",
       "1_27        3          3        0      0        0      9\n",
       "1_15        5          1        0      0        0      7\n",
       "1_16        1          1        0      0        0      3\n",
       "1_17        1          1        0      0        0      3\n",
       "1_4         1          0        0      0        0      1\n",
       "1_9         1          0        0      0        0      1"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "baseline.loc['10915379'].sort_values('score', ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>view</th>\n",
       "      <th>deep_view</th>\n",
       "      <th>collect</th>\n",
       "      <th>share</th>\n",
       "      <th>comment</th>\n",
       "      <th>score</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>cate_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1_2</th>\n",
       "      <td>27</td>\n",
       "      <td>14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_3</th>\n",
       "      <td>16</td>\n",
       "      <td>15</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_1</th>\n",
       "      <td>8</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_15</th>\n",
       "      <td>10</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_6</th>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3_1</th>\n",
       "      <td>6</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_17</th>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1_11</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3_2</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3_3</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         view  deep_view  collect  share  comment  score\n",
       "cate_id                                                 \n",
       "1_2        27         14        0      0        0     55\n",
       "1_3        16         15        0      0        0     46\n",
       "1_1         8          7        0      0        0     22\n",
       "1_15       10          6        0      0        0     22\n",
       "1_6         9          5        0      0        0     19\n",
       "3_1         6          4        0      0        0     14\n",
       "1_17        4          4        0      0        0     12\n",
       "1_11        3          3        0      0        0      9\n",
       "3_2         1          1        0      0        0      3\n",
       "3_3         1          1        0      0        0      3"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "baseline.loc['16083308'].sort_values('score', ascending=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
